<template>
  <div class="news-details">
    <!--已读和未读tab-->
    <!--<ul class="details-header row bg_ff col_333">-->
      <!--<li class="details-nav col"-->
          <!--v-text="item.name"-->
          <!--v-for="(item,index) in items"-->
          <!--@click="toggleClick(index)"-->
          <!--:class="{active:item.isActive}"-->
      <!--&gt;</li>-->
    <!--</ul>-->
    <ul class="details-header row bg_ff col_333">
      <li class="details-nav col" :class="{active:focusIndex==0}" @click="toggleClick(0)">未读</li>
      <li class="details-nav col" :class="{active:focusIndex==1}" @click="toggleClick(1)">已读</li>
    </ul>


    <!--未读详情-->
    <div class="unread-data">
      <div class="unread-data-list">

        <!--//未读信息展示-->
        <div v-if="focusIndex==0">
          <div v-if="n_read.length">
            <div class="unread-data-item row bg_ff" v-for="i in n_read" :key="i.notifySeq" @click="goMessage(i)">
              <div class="details-img">
                <img src="../../../static/image/paysign3.png" v-if="i.phoneType == '0001'">
                <img src="../../../static/image/paysign2.png" v-if="i.phoneType == '0003'">
                <img src="../../../static/image/paysign1.png" v-if="i.phoneType == '0002'">
              </div>
              <div class="data-all">
                <div class="row data-top">
                  <h4 class="tl col_333 col" v-if="i.phoneType == '0001'">通知公告</h4>
                  <h4 class="tl col_333 col" v-if="i.phoneType == '0002'">签约提醒</h4>
                  <h4 class="tl col_333 col" v-if="i.phoneType == '0003'">待缴费用</h4>
                  <!--<h4 class="tl col_333 col" v-if="i.phoneType == '0003' && i.payStatus == 'P-00'">已缴费用</h4>-->
                  <!--<span class="wait-pay-img" v-if="i.phoneType == '0003' && i.payStatus == '04'"></span>-->
                  <!--<span class="payed-img" v-if="i.phoneType == '0003' && i.payStatus == 'P-00'"></span>-->
                </div>
                <div class="row data-mid">
                  <p class="tl">{{i.notifyContext}}</p>
                  <!--<p class="col-50" v-if="i.phoneType == '0003' && i.payStatus == '04'">应缴费用：&nbsp;<span>{{i.totalAmt}}</span>元</p>-->
                  <!--<p class="col-50" v-if="i.phoneType == '0003' && i.payStatus == 'P-00'">已缴费用：&nbsp;<span>{{i.factAmt}}</span>元</p>-->
                </div>
                <div class="data-footer">{{i.findDate}}</div>
              </div>
            </div>
          </div>
          <div v-else="" class="noNew_style">
            <no-data :noParams = 'noParams'></no-data>
          </div>
        </div>
        <!--//已读信息展示-->
        <div v-if="focusIndex==1">
          <div v-if="y_read.length">
            <div class="unread-data-item row bg_ff" v-for="i in y_read" :key="i.notifySeq" @click="goMessage(i)">
              <div class="details-img">

                <img src="../../../static/image/paysign3.png" v-if="i.phoneType == '0001'">
                <img src="../../../static/image/paysign2.png" v-if="i.phoneType == '0003'">
                <img src="../../../static/image/paysign1.png" v-if="i.phoneType == '0002'">
              </div>
              <div class="data-all">
                <div class="row data-top">
                  <h4 class="tl col_333 col" v-if="i.phoneType == '0001'">通知公告</h4>
                  <h4 class="tl col_333 col" v-if="i.phoneType == '0002'">签约提醒</h4>
                  <h4 class="tl col_333 col" v-if="i.phoneType == '0003'">待缴费用</h4>
                  <!--<h4 class="tl col_333 col" v-if="i.phoneType == '0003' && i.payStatus == 'P-00'">已缴费用</h4>-->
                  <!--<span class="wait-pay-img" v-if="i.phoneType == '0003' && i.payStatus == '04'"></span>-->
                  <!--<span class="payed-img" v-if="i.phoneType == '0003' && i.payStatus == 'P-00'"></span>-->
                </div>
                <div class="row data-mid">
                  <p class="tl">{{i.notifyContext}}</p>
                  <!--<p class="col-50" v-if="i.phoneType == '0003' && i.payStatus == '04'">应缴费用：&nbsp;<span>{{i.totalAmt | formatNumber}}</span>元</p>-->
                  <!--<p class="col-50" v-if="i.phoneType == '0003' && i.payStatus == 'P-00'">已缴费用：&nbsp;<span>{{i.factAmt | formatNumber}}</span>元</p>-->
                </div>
                <div class="data-footer">{{i.findDate}}</div>
              </div>
            </div>
          </div>
          <div v-else="" class="noNew_style">

            <no-data :noParams = 'noParams'></no-data>

          </div>
        </div>

      </div>
    </div>
  </div>
</template>

<script>

  import Vue from 'vue'
  import Router from 'vue-router'
  import { MessageBox } from 'mint-ui';
  import noData from "../common/noData.vue";
  const router = new Router({})

  export default {
    components: {noData},
    data () {
      return {
        focusIndex:0,
        n_read: [],   //未读
        y_read: [] ,   //已读
        noParams: {
          src: '../../../static/image/noNew.png',
          text: '亲，暂无任何消息提醒哦～'
        }
      }
    },
    methods: {
      toggleClick:function (index) {
        this.focusIndex = index;
      },
      goMessage: function (item) {
        var that = this;
        MessageBox('消息详情', item.notifyContext).then(function () {
          //未读到已读的转换
          if(item.isRead == 0){
            that.$post(that.$urlAll.update_read, {phoneType:item.phoneType, notifyId:item.notifySeq, userId: item.feeUserId, openAccount: sessionStorage.getItem('userId')},).then(function (response) {
              router.go(0)

            });
          }
        });
      }
    },
    //获取后台数据，dom渲染之前
    created: function(){
      var that = this;

      this.$post(this.$urlAll.get_notify_list, {type:this.$route.query.phoneType, openAccount: sessionStorage.getItem('userId')}).then(function (response) {

        if(response.t.bNotifyListN.length){
          that.n_read = response.t.bNotifyListN
        }

        if(response.t.bNotifyListY.length){
          that.y_read = response.t.bNotifyListY
        }

      });
    }
  }
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  @import "../../style/common.css";



  .details-header{
    text-align: center;
  }
  .details-header .details-nav{
    height: 0.44rem;
    line-height: 0.44rem;
    font-size: 0.16rem;
  }
  .details-header .active{
    color: #ff4444;
    border-bottom: 0.01rem solid #ff4444;
  }
  .unread-data-item{
    margin-top: 0.1rem;
  }
  .unread-data-item p{
    overflow: hidden;
    -ms-text-overflow: ellipsis;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .details-img{
    width: 0.5rem;
    text-align: center;
    padding-top: 0.085rem;
  }
  .details-img>img{
    width: 0.27rem;
    height: 0.27rem;
    flex:none;
  }
  .data-all{
    width: calc(100% - 0.5rem);
  }
  .data-top{
    height: 0.44rem;
    line-height: 0.44rem;
    border-bottom: 0.01rem solid #EEEEEE;
  }
  .data-top>span{
    flex:none;
    width: 0.41rem;
    height: 0.41rem;
    background-size: 100% 100%;
  }
  .wait-pay-img{
    background: url("../../assets/image/wait_pay.png") no-repeat;
  }
  .payed-img{
    background: url("../../assets/image/payed.png") no-repeat;

  }
  .data-mid{
    height: 0.32rem;
    line-height: 0.32rem;
    font-size: 0.13rem;
    color: #666666;
  }
  .data-footer{
    height: 0.32rem;
    line-height: 0.32rem;
    font-size: 0.11rem;
    color: #999999;
  }
</style>
